/**
 * @author WYX
 * @date 2020/5/15
 * @Description: 工具装饰器类
*/
export class UtilsDec {
  static LimitRunTimes(times: number) {
    let checktime = 0;
    return (target: any, propertyKey: string, descriptor: PropertyDescriptor): void => {
      // 保存现有方法
      const setFunction = descriptor.value;

      descriptor.value = function(...arg: any): void {
        if (checktime % times === 0) {
          setFunction.call(this, ...arg);
          checktime = 0;
        }
        checktime++;
      };
    };
  }
}
